package com.shine.log.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shine.common.response.Result;
import com.shine.log.info.RequestLogInfo;
import com.shine.log.request.RequestLogPageRequest;
import com.shine.log.service.RequestLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author huihui
 * @date 2025/05/07 14:47
 * @description RequestLogController
 */
@Slf4j
@Tag(name = "请求日志表 Controller", description = "请求日志表 Controller")
@RestController
@RequestMapping("/requestLog")
public class RequestLogController {

    @Resource
    private RequestLogService requestLogService;

    @GetMapping("/page")
    @Operation(summary = "请求日志表分页查询")
    public Result<IPage<RequestLogInfo>> pageQueryRequestLog(RequestLogPageRequest request) {
        IPage<RequestLogInfo> requestLogPage = requestLogService.pageQuery(request);
        return Result.success(requestLogPage);
    }

    @GetMapping("/get/{id}")
    @Operation(summary = "请求日志表详情查询")
    public Result<RequestLogInfo> getRequestLogById(@PathVariable("id") Long id) {
        RequestLogInfo requestLog = requestLogService.getById(id);
        return Result.success(requestLog);
    }

}